package exsun.jt808.data.kafka_data;

import exsun.jt808.data.base.MsgDirection;
import exsun.jt808.data.util.GsonUtils;
import exsun.jt808.data.util.HostUtil;
import lombok.Data;

import java.util.Date;

/**
 * @Description: kafka数据包
 */
@Data
public class KafkaJT809Data<T> extends KafkaDataBase<T>{

    public void KafkaJT809Data(int msgId, String topic, T object, MsgDirection direction){
        this.msgId = msgId;
        this.topic = topic;
        this.object = object;
        this.hostName = HostUtil.hostName;
        this.direction = direction;
        this.date = new Date();
    }

    public KafkaJT809Data(T data, int mid, String tpc, MsgDirection direction){
        KafkaJT809Data(mid, tpc, data, direction);
    }

    MsgDirection direction;

    public String getJsonFromObject(){
        return GsonUtils.getJsonFromObject(this);
    }

}
